<template>
  <div class="tab-title-page my_index">
    <div class="flex data_wrap">
      <div
        class="flex-1"
        style="padding-left:80px"
      >
        <div class="flex">
          <img
            class="money_icon"
            src="../../assets/images/balance.png"
            alt="可提现金额"
          >
          <div
            class="flex-1"
            style="line-height:23px"
          >
            <p>可提现金额（元）<span
                class="blue-font pointer"
                @click="$router.push({name:'myFlow'})"
              >账单明细</span></p>
            <p class="red-font money_data">{{balance}}</p>
          </div>
        </div>
        <p style="margin-top:25px">
          <el-button
            v-if="$hasMethod('#recharge')"
            type="primary"
            size="small"
            @click="goToRecharge"
          >充值</el-button>
          <el-button
            v-if="$hasMethod('#withdraw')&&balance>0"
            type="warning"
            size="small"
            @click="$router.push({name:'myWithdraw'})"
          >提现</el-button>
        </p>
      </div>
      <div
        class="flex-1"
        style="border-left:1px solid #e6e6e6;padding-left:80px"
      >
        <div class="flex">
          <img
            class="money_icon"
            src="../../assets/images/frozen.png"
            alt="冻结金额"
          >
          <div
            class="flex-1"
            style="line-height:23px"
          >
            <p>冻结金额（元）</p>
            <p class="red-font money_data">{{frozen}}</p>
          </div>
        </div>
        <p
          style="margin-top:35px"
          class="color-999"
        >冻结金额为正在提现的金额</p>
      </div>
    </div>
    <el-divider class="middle_divider"></el-divider>
    <div class="child_page">
      <div class="flex align-center table-top-btns">
        <h5 class="flex align-center">
          <svg-icon
            style="margin-right:15px"
            icon-class="list"
            :size="15"
          />提现记录
        </h5>
      </div>
      <el-table
        border
        :data="tableData"
      >
        <el-table-column
          align="center"
          prop="apply_time"
          label="创建时间"
          width="100"
        />
        <el-table-column
          align="center"
          prop="withdrawal_amount"
          label="提现金额（元）"
        />
        <el-table-column
          align="center"
          label="提现状态"
        >
          <template slot-scope="scope">
            <span>{{scope.row.status==1?'待审核':scope.row.status==2?'已入账':scope.row.status==3?'未入账':'提现拒绝'}}</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          label="提现方式"
        >
          <template slot-scope="scope">
            <span>{{scope.row.pay_type==1?'支付宝':''}}</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          label="收款人信息"
        >
          <template slot-scope="scope">
            <span>{{scope.row.payee_account}}{{scope.row.payee_name}}</span>
          </template>
        </el-table-column>
      </el-table>
      <custom-page
        ref="customPage"
        :total="total"
        @getList="getList"
      ></custom-page>
    </div>
  </div>
</template>

<script>
import { myAccount } from "@/api/account";
import customPage from "@/components/customPage";
import { withdrawalList } from "@/api/finance";
export default {
  components: { customPage },
  data() {
    return {
      balance: 0,
      frozen: 0,
      tableData: [],
      total: 0
    }
  },
  methods: {
    goToRecharge() {
      let routeData = this.$router.resolve({
        name: "recharge"
      });
      window.open(routeData.href, '_blank');
    },
    getData() {
      myAccount().then(res => {
        const { balance, frozen } = res;
        this.balance = balance;
        this.frozen = frozen;
      })
    },
    // 获取数据
    getList() {
      const { page, pageSize } = this.$refs.customPage;
      withdrawalList({
        page,
        pageSize,
        adminMobile: '',
        status: '',
        arrivalTime: ''
      }).then(res => {
        this.tableData = res.data || [];
        this.total = res.total || 0;
      })
    },
  },
  mounted() {
    this.getData();
    this.getList();
  }
}
</script>

<style lang="scss" scoped>
.child_page {
  padding: 15px;
}
.data_wrap {
  padding: 20px 0;
  background-color: #ffffff;
  border-radius: 0 0 10px 10px;
}
.money_icon {
  width: 55px;
  height: 55px;
  margin-right: 15px;
}
.money_data {
  font-size: 28px;
  margin-top: 10px;
}
</style>